package com.hao.hospital.service;

import com.hao.hospital.model.Drug;
import com.jfinal.aop.Enhancer;
import com.jfinal.plugin.activerecord.Record;

import cn.jlook.jfinal.ext3.kit.SqlBuilder;

public class DrugService extends AbstractService {
	private static DrugService me;

	public static DrugService me() {
		if (null == me) {
			me = Enhancer.enhance(DrugService.class);
		}
		return me;
	}
	/**
	 * 通过药品名称查看单个药品信息
	 * @param drug_name
	 * @return
	 */
	public Record druginfo(String drug_name){
		Record data=SqlBuilder.from(Drug.table).where("drug_name=?").find(drug_name);
		if(data==null){
			return new Record();
		}else{
			return data;
		}
	}
	public int drugupdate(String drug_name,int num){
		return SqlBuilder.from(Drug.table).where("drug_name=?",drug_name).update("drug_num=drug_num+?",num);
	}
}
